package design.factory;

import design.factory.AbstractFactory.Engine;
import design.factory.AbstractFactory.ICarFactory1;
import design.factory.AbstractFactory.LuxuryCarFactory;
import design.factory.factoryMethod.AudiFactory;
import design.factory.factoryMethod.BydFactory;
import design.factory.simpleFactory.CarFactory;

public class Client01 {
    public static void main(String[] args) {
        // 非工厂模式
        Audi audi = new Audi();
        Byd byd = new Byd();
        audi.run();
        byd.run();

        // 简单工厂模式
        Audi audi1 = (Audi) CarFactory.createCar("奥迪");
        Byd byd1 = (Byd) CarFactory.createCar("比亚迪");
        audi1.run();
        byd1.run();

        // 工厂方法模式
        AudiFactory factory1 = new AudiFactory();
        Audi audi2 = (Audi) factory1.createCar();

        BydFactory factory2 = new BydFactory();
        Byd byd2 = (Byd) factory2.createCar();
        audi2.run();
        byd2.run();

        // 抽象工厂
        ICarFactory1 factory3 = new LuxuryCarFactory();
        Engine e = factory3.createEngine();
        e.run();
        e.start();
        factory3.createSeat();
        factory3.createTyre();
    }
}
